package com.qfedu.controller;

import com.qfedu.common.JsonBean;
import com.qfedu.pojo.SysCity;
import com.qfedu.service.SysCityService;
import com.qfedu.utils.JsonUtils;
import com.qfedu.vo.VCity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;


@Controller
@RequestMapping("/city")
public class SysCityController {
    @Autowired
    private SysCityService cityService;

    //取车地址和还车地址的选择
    @RequestMapping("/select.do")
    @ResponseBody
    public JsonBean selectAll(Integer pid) {
        JsonBean bean = null;

        try {
            List<SysCity> list = cityService.selectAll(pid);
            bean = JsonUtils.createJsonBean(1, list);
        } catch (Exception e) {
            bean = JsonUtils.createJsonBean(0, e.getMessage());
        }
        return bean;
    }


    //取车地址和还车地址显示
    @RequestMapping("/citys.do")
    @ResponseBody
    public JsonBean selectCity(Integer getid, Integer backid) {

        JsonBean bean = null;

        try {
            VCity vCity = cityService.selectCitys(getid, backid);
            bean = JsonUtils.createJsonBean(1, vCity);
        } catch (Exception e) {
            bean = JsonUtils.createJsonBean(0, e.getMessage());
        }
        return bean;
    }
}